home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1984 December / 1984-12.d64 / disk backup (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  254 lines

  1. 10 sys65517:ifpeek(781)=40thenmt$="":goto30
  2. 20 mt$=""
  3. 30 gosub1580:ifbr$="r"then450
  4. 40 fors1=k1tonf:gosub930
  5. 50 get#fp,a$:a$=mid$(a$+c0$,k1,k1):zt=st
  6. 60 bk=bk+k1:print up$;tab(17);bk:r$=""
  7. 70 geti$:ifi$<>""goto330
  8. 80 lb$=a$:lb=asc(lb$):ne=k1
  9. 90 ifztthengosub150:gosub220:goto250
  10. 100 get#fp,a$:a$=mid$(a$+c0$,k1,k1):zt=st
  11. 110 iflen(r$)>cmthengosub150:gosub220:goto60
  12. 120 iflb$<>a$then140
  13. 130 ifne<250thenne=ne+k1:goto90
  14. 140 gosub150:goto80
  15. 150 ifne>k1goto190
  16. 160 iflb<csthenr$=r$+lb$:return
  17. 170 iflb<233 or lb=245thenr$=r$+chr$(230)+lb$:return
  18. 180 r$=r$+lb$:return
  19. 190 iflb=spthenr$=r$+cs$+chr$(ne):return
  20. 200 iflb=dathenr$=r$+chr$(245)+chr$(ne):return
  21. 210 r$=r$+chr$(231)+chr$(ne)+lb$:return
  22. 220 l$=mid$(str$(len(r$)+k4),k2)
  23. 230 print#1,mid$(l$+sp$,k1,k3);"d";r$;
  24. 240 nb=nb+len(r$)+4:return
  25. 250 gosub410:print up$;tab(30);nb
  26. 260 gosub2490:close fp
  27. 270 nexts1
  28. 280 print"to restore files load this";
  29. 290 print" program from the backup tape"
  30. 300 gosub 860
  31. 310 forsl=k1to20:next
  32. 320 goto 2480
  33. 330 print"q quit, space continue"
  34. 340 geti$:ifi$=""goto340
  35. 350 ifi$<>"q"goto370
  36. 360 closefp:an$="a":gosub410:goto2480
  37. 370 print up$ "                       " up$
  38. 380 print chr$(18) " p to pause" chr$(146) up$:goto80
  39. 390 print#1,"024f";mid$(na$+sp$,k1,16);mid$(ty$,k1,k1);mid$(ln$+sp$,k1,k3);
  40. 400 nb=nb+24:return
  41. 410 print#1,"005e";an$:nb=nb+8:print#1,c0$;c0$;c0$;:close1:return
  42. 420 en=len(dt$)
  43. 430 ifasc(mid$(dt$,en,1))<>160thenreturn
  44. 440 dt$=left$(dt$,en-k1):goto420
  45. 450 gosub1110
  46. 460 for s1=k1tonf
  47. 470 bk=k0:na$=na$(s1):ty$=ty$(s1)
  48. 480 open 1,1,0:nb=nb+300:gosub840
  49. 490 fm$="":print:print up$ chr$(18) " found" chr$(146) " ";
  50. 500 ifrc$<>"f"thenclose1:goto480
  51. 510 forx=k1to16:get#1,i$:fm$=fm$+i$:next
  52. 520 print fm$:get#1,a$,a$,a$,a$
  53. 530 iffm$=na$goto580
  54. 540 gosub840:ifrc$="n"thenclose1:gosub1520:goto480
  55. 550 nb=nb+ln:forx=k1toln-k4:get#k1,a$:next:gosub840
  56. 560 ifrc$="d"goto550
  57. 570 close1:goto480
  58. 580 x=len(na$):ifmid$(na$,x,k1)=" "thenna$=mid$(na$,k1,x-k1):goto580
  59. 590 openfp,8,fp,"@0:"+na$+co$+ty$+",w"
  60. 600 gosub840:ifrc$="d"goto640
  61. 610 ifrc$="e"goto760
  62. 620 ifrc$="n"thengosub1510:goto470
  63. 630 print " expected d or e":goto2480
  64. 640 bk=bk+k1:print up$;tab(24);bk
  65. 650 l=0
  66. 660 l=l+k1:ifl>ln-k4goto600
  67. 670 get#1,a$:a$=mid$(a$+c0$,k1,k1):a=asc(a$)
  68. 680 ifa<230thenprint#fp,a$;:goto660
  69. 690 ifa=230thenget#1,a$:l=l+k1:a$=mid$(a$+c0$,k1,k1):print#fp,a$;:goto660
  70. 700 ifa=231then730
  71. 710 ifa=232 or a=245 then750
  72. 720 print#fp,a$;:goto660
  73. 730 get#1,a$,a1$:l=l+k2:a1$=mid$(a1$+c0$,k1,k1)
  74. 740 forx=k1toasc(a$):print#fp,a1$;:next:goto660
  75. 750 get#1,a1$:l=l+k1:forx=k1toasc(a1$):print#fp,chr$(a-200);:next:goto660
  76. 760 gosub2490:close1:close fp
  77. 770 if a$<>"a"goto820
  78. 780 print " file'" na$ "' is incomplete
  79. 790 [153]"q to quit, space to continue
  80. 800 geta$:ifa$=""goto800
  81. 810 ifa$="q"goto2480
  82. 820 next s1:gosub860
  83. 830 forsl=k1to20:next:goto2480
  84. 840 get#1,l1$,l2$,l3$,rc$
  85. 850 ln=val(l1$+l2$+l3$):nb=nb+ln:return
  86. 860 tt=val(mid$(ti$,k1,k2))*3600+val(mid$(ti$,k3,k2))*60
  87. 870 tt=tt+int(nb/25):hh=int(tt/3600)
  88. 880 mm=int((tt-hh*3600)/60)
  89. 890 hh$=mid$(str$(hh),2):iflen(hh$)<2thenhh$="0"+hh$
  90. 900 mm$=mid$(str$(mm),2):iflen(mm$)<2thenmm$="0"+mm$
  91. 910 ti$=hh$+mm$+"00":print "estimated time=";ti$
  92. 920 return
  93. 930 na$=na$(s1):ty$=ty$(s1)
  94. 940 ifnb+ln(s1)*(bd+5)+bh<tb goto1050
  95. 950 open 1,1,1,na$:gosub390
  96. 960 print#1,"004n";:close1
  97. 970 print " load another cassette"
  98. 980 print "   type q to quit,"
  99. 990 print "  space to continue"
  100. 1000 geta$:if a$="" then1000
  101. 1010 if a$="q" goto2480
  102. 1020 print " tape size (min) ";tm;mid$(bs$,1,len(str$(tm))+2);
  103. 1030 input tm$:iftm$=""thentm$=str$(tm)
  104. 1040 tb=val(tm$)*bm:gosub860:nb=k0
  105. 1050 print sp$;cr$
  106. 1060 print"    [145]p to pause[146]":printup$ up$
  107. 1070 printna$:bk=k0
  108. 1080 ln$=mid$(str$(ln(s1)),k2)
  109. 1090 open fp,8,fp,"0:"+na$+co$+ty$+",r"
  110. 1100 open 1,1,1,na$:nb=nb+bh:gosub390:return
  111. 1110 print " format disk (n or y)"
  112. 1120 input" ";a$
  113. 1130 ifa$<>"y"goto1200
  114. 1140 nd$="":print " disk name";
  115. 1150 inputnd$:ifnd$=""goto1200
  116. 1160 id$="":print " disk id  ";
  117. 1170 inputid$:ifid$=""goto1200
  118. 1180 print#15,"n0:";nd$;",";id$
  119. 1190 gosub 2490:ife1then2490
  120. 1200 print " open dtb.id.file"
  121. 1210 open 1,1,0,"dtb.id.file"
  122. 1220 nb=nb+300
  123. 1230 gosub840
  124. 1240 get#1,a$
  125. 1250 ifa$<>vn$ thenprint " version error":goto2480
  126. 1260 print "[147] from disk:";
  127. 1270 forx=1to20:get#1,a$:print a$;:next
  128. 1280 print:print "backed up on  date:";
  129. 1290 forx=1to8 :get#1,a$:print a$;:next
  130. 1300 print " time:";
  131. 1310 forx=1to6 :get#1,a$:print a$;:next
  132. 1320 print
  133. 1330 nf=0
  134. 1340 gosub840
  135. 1350 ifrc$="f" then1380
  136. 1360 ifrc$="e" then close1:return
  137. 1370 print " rec cd error":goto2480
  138. 1380 na$="":forx=1to16:get#1,a$:printa$;
  139. 1390 na$=na$+a$:next
  140. 1400 get#1,ty$:print" "ty$" ";
  141. 1410 get#1,a$,a2$,a3$:print a$;a2$;a3$;
  142. 1420 print:ifaf$="y"then1480
  143. 1430 print up$:print"bkup y or n";
  144. 1440 yn$="":input yn$
  145. 1450 ifmid$(yn$+"y",k1,k1)="y"goto1480
  146. 1460 if yn$="n"goto1340
  147. 1470 goto1430
  148. 1480 nf=nf+k1
  149. 1490 na$(nf)=na$:ty$(nf)=ty$:goto1340
  150. 1500 return
  151. 1510 closefp:close1
  152. 1520 print" load continuation tape"
  153. 1530 print" type q to quit"
  154. 1540 print"      space to continue"
  155. 1550 geta$:ifa$=""goto1550
  156. 1560 ifa$="q"goto2480
  157. 1570 gosub860:nb=0:return
  158. 1580 dim ln(150),na$(150),t$(4),ty$(150)
  159. 1590 bh=300:bd=256:bk=0:bm=840:bo=53280:cm=250:cs=230:da=45:dir=8:fp=5
  160. 1600 k0=0:k1=1:k2=2:k3=3:k4=4
  161. 1610 nb=0:nc=0:ne=0:nf=0:ps=8000:sp=32:tb=0:tm=60
  162. 1620 af$="":an$="n":br$="":forx=1to40:bs$=bs$+chr$(157):next
  163. 1630 c0$=chr$(0):cb$="":co$=",":cs$=chr$(232)
  164. 1640 da$="":dn$="":fm$="":rc$="":sp$="         ":sp$=sp$+sp$+sp$:up$=chr$(145)
  165. 1650 vn$="2"
  166. 1660 open15,8,15:poke bo,0
  167. 1670 printmt$:printchr$(147):print"  disk to tape backup"
  168. 1680 t$(k0)="del":t$(1)="seq":t$(2)="prg":t$(3)="usr":t$(4)="rel"
  169. 1690 print"backup or restore":input"(b or r)";br$
  170. 1700 br$=mid$(br$+" ",1,1)
  171. 1710 if br$<>"b" and br$<>"r" goto2480
  172. 1720 print"process all files":input"(y or n)";af$
  173. 1730 af$=mid$(af$+"y",1,1)
  174. 1740 if af$<>"y" and af$<>"n" goto2480
  175. 1750 if br$="r"then1890
  176. 1760 print "tape size (min) ";tm;mid$(bs$,1,len(str$(tm))+2);
  177. 1770 input tm$:iftm$=""thentm$=str$(tm)
  178. 1780 tm=val(tm$):tb=tm*bm
  179. 1790 open 3,8,3,"0:sys date,s,r"
  180. 1800 input#15,e1,e2$,e3,e4
  181. 1810 if e1 then d$="00/00/00":goto1830
  182. 1820 input#3,d$
  183. 1830 close3
  184. 1840 print " mm/dd/yy ";
  185. 1850 input da$:if da$="" then da$=d$
  186. 1860 if d$=da$ goto1890
  187. 1870 da$=mid$(da$+"        ",1,8):open 3,8,3,"@0:sys date,s,w":
  188. 1880 gosub2490:print#3,da$:close3
  189. 1890 t$=ti$
  190. 1900 print " hhmm     ? "t$;mid$(bs$,1,len(t$)+2);
  191. 1910 input t$:ti$=mid$(t$+"000000",1,6)
  192. 1920 if br$="r"thenreturn
  193. 1930 print"[147]  reading directory":open dir,8,dir,"$"
  194. 1940 for l=k1 to 142:get#dir,a$:next
  195. 1950 dn$="":forl=k1to16:get#dir,a$
  196. 1960 dn$=dn$+a$:next:print "[147] disk:"dn$;
  197. 1970 dt$=dn$:gosub420:dn$=dt$
  198. 1980 get#dir,a$,a$,i1$,i2$,a$,o1$,o2$
  199. 1990 print" id:";i1$;i2$;:print" os:";o1$;o2$""
  200. 2000 for l=k1to89:get#dir,a$:next
  201. 2010 nf=0
  202. 2020 rb=dir:r$=""
  203. 2030 forr=k1to254:get#rb,a$:r$=r$+mid$(a$+c0$,k1,k1):next:zs=st
  204. 2040 b=k0
  205. 2050 print"[147] disk:"dn$;
  206. 2060 printtab(23)"id:";i1$;i2$;:print" os:";o1$;o2$""
  207. 2070 for p=k1 to 8
  208. 2080 t=asc(mid$(r$,b+k1)):ift=k0thent=128
  209. 2090 l=asc(mid$(r$,b+29)):h=asc(mid$(r$,b+30))
  210. 2100 l=(l+256*h):ifl=k0then2200
  211. 2110 n$=mid$(r$,b+k4,16)
  212. 2120 ty$=t$(t-128):if ty$="del"then2200
  213. 2130 dt$=n$:gosub420:n$=dt$
  214. 2140 print l;tab(4);ty$;"  ";n$
  215. 2150 ifaf$="y" then print:goto2180
  216. 2160 print" y/n ? y";mid$(bs$,1,3);
  217. 2170 yn$="":inputyn$:ifyn$="n"goto2200
  218. 2180 nf=nf+k1:na$(nf)=n$
  219. 2190 ty$(nf)=mid$(ty$,k1,k1):ln(nf)=l
  220. 2200 b=b+32:next p:print"  please wait..."
  221. 2210 if zs=k0 then2020
  222. 2220 close dir
  223. 2230 if nf<k2then2360
  224. 2240 fori=1to2000:next:print "[147]     sorting ...."
  225. 2250 fors1=k1tonf-k1:sm=s1
  226. 2260 fors2=s1+k1tonf
  227. 2270 if na$(sm)>na$(s2)thensm=s2
  228. 2280 nexts2
  229. 2290 ifsm=s1then2330
  230. 2300 na$(k0)=na$(s1):na$(s1)=na$(sm):na$(sm)=na$(0)
  231. 2310 ty$(k0)=ty$(s1):ty$(s1)=ty$(sm):ty$(sm)=ty$(0)
  232. 2320 ln(k0)=ln(s1):ln(s1)=ln(sm):ln(sm)=ln(0)
  233. 2330 print " " na$(s1)
  234. 2340 nexts1:print" "na$(nf):print
  235. 2350 gosub 2520:nb=nb+ps
  236. 2360 open 1,1,1,"dtb.id.file"
  237. 2370 nb=nb+bh+39
  238. 2380 print#1,"039v";vn$;
  239. 2390 print#1,mid$(dn$+sp$,k1,20);
  240. 2400 print#1,mid$(da$+sp$,k1,8);ti$;
  241. 2410 fors1=k1tonf
  242. 2420 ln$=mid$(str$(ln(s1)),k2)
  243. 2430 na$=na$(s1):ty$=ty$(s1)
  244. 2440 gosub390
  245. 2450 nexts1:gosub 410
  246. 2460